//
//  ZHSaveClickDate.m
//  Doctor
//
//  Created by liuzhishan on 15/12/23.
//  Copyright © 2015年 shanshan. All rights reserved.
//

#import "ZHArrayTool.h"
#import "ZHClinicAllData.h"

@implementation ZHSaveClickDate

static ZHSaveClickDate *singleData = nil;

+(instancetype)shareData
{
    
    if(singleData == nil)
    {
        
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        singleData = [[ ZHSaveClickDate alloc]init];
        singleData.judgeModel = [[ZHSaveCommenMeg alloc] init];
        
    });
        
        
    }
    
    
    return singleData;
}
+(void)getClassValueWithArray:(NSMutableArray *)array andSingleName:(NSString *)name
{
    
    CGFloat minA = MAXFLOAT;
    CGFloat maxA = 0;
    
    CGFloat minB = MAXFLOAT;
    CGFloat maxB = 0;
    


    
    
    for (ZHClinicAllData *model  in array) {
        
        if ([name isEqualToString:@"income"] ) {
            
            if (model.topPrice < minA) {
                
                minA = model.topPrice;
            }
            
            if (model.topPrice > maxA) {
                
                maxA = model.topPrice;
            }
            
            if (model.money < minB) {
                
                minB = model.money;
            }
            
            if (model.money > maxB) {
                
                maxB = model.money;
            }
            
            
        }
        
        
         else if ([name isEqualToString:@"patient"] ) {
            
            if (model.firstVisit < minA) {
                
                minA = model.firstVisit;
            }
            
            if (model.firstVisit > maxA) {
                
                maxA = model.firstVisit;
            }
            
            if (model.secondVisit < minB) {
                
                minB = model.secondVisit;
            }
            
            if (model.secondVisit > maxB) {
                
                maxB = model.secondVisit;
            }
            
            
            
        }

        
    }
    
    
    CGFloat allMin = minA < minB ? minA : minB;
    CGFloat allMax = maxA > maxB ? maxA : maxB;
    
    
    
    
    singleData.judgeModel.max = allMax;
    singleData.judgeModel.min = allMin;
    
    singleData.judgeModel.judgeName = name;
 
    
    
        
    
    
    
    
}



+(void)getClassValueWithArray:(NSMutableArray *)array
{
    
    NSMutableArray *minArray = [ NSMutableArray array];
    NSMutableArray *maxArray = [NSMutableArray array];
    
    
    
    NSMutableArray *tempA = [NSMutableArray array];
    NSMutableArray *tempB = [NSMutableArray array];
    NSMutableArray *tempC = [NSMutableArray array];
    
    for (ZHClinicAllData *model  in array) {
        
        [tempA addObject:[NSNumber numberWithInteger:(model.patienterNumber-model.appointmentNumber- model.notArrive)]];
        [tempB addObject:[NSNumber numberWithInteger:model.appointmentNumber]];
        [tempC addObject:[NSNumber numberWithInteger:model.notArrive]];
        
        
    }
    
    [minArray addObject:[NSNumber numberWithFloat:[ZHArrayTool getTheMinInDataArray:tempA]]];
    [minArray addObject:[NSNumber numberWithFloat:[ZHArrayTool getTheMinInDataArray:tempB]]];
    [minArray addObject:[NSNumber numberWithFloat:[ZHArrayTool getTheMinInDataArray:tempC]]];
    
    [maxArray addObject:[NSNumber numberWithFloat:[ZHArrayTool getTheMaxInDataArray:tempA]]];
    [maxArray addObject:[NSNumber numberWithFloat:[ZHArrayTool getTheMaxInDataArray:tempB]]];
    [maxArray addObject:[NSNumber numberWithFloat:[ZHArrayTool getTheMaxInDataArray:tempC]]];
    
    
    singleData.judgeModel.max = [ZHArrayTool getTheMaxInDataArray:maxArray];
    singleData.judgeModel.min = [ZHArrayTool getTheMinInDataArray:minArray];
  
 
    
    
    

}


@end
